import { createRouter, createWebHistory, } from 'vue-router'
// 路由懒加载
const HelloWorld = () => import('../view/HelloWorld.vue')


// 配置router对象
const router = createRouter({
    // 路由模式
    history: createWebHistory(),  //使用History模式，需要后端配合配置
    // history: createWebHashHistory(),  //hash模式
    // 动态路由/路由懒加载
    routes: [
        {
            path: "/",
            component: HelloWorld
        },
        {
            path: "/login",
            name: "login",
            component: () => import('../view/login.vue')
        }

    ],
})

// 路由导航守卫
// router.beforeEach((to, from, next) => {
//     if (to.path === '/') { return next() }
//     let tokenStr = window.localStorage.getItem('token')
//     if (!tokenStr) return next('/')
//     next()
// });

export default router

